Repository navigation
Conversation
The engine now holds a UUID, so the addon stops refusing one. A VcUuid is written as the engine's UUID and decrypts back as a VcUuid. A string that holds a UUID is still text. - js.rs and error.rs: delete `is_uuid` and the `recipher_js::uuid` error. - The TypeScript types: `VcUuid` is a `Scalar` and decrypts as a `VcUuid`, and `kinds.uuid` names the kind, for `Ciphertext.fromBytes` and for a record field. - Tests: a VcUuid round trip and a read with `kinds.uuid`; the engine opens the addon's UUID as its own UUID type, and the addon opens the engine's; a record with a uuid field is stored, found by equality (the same UUID gives the stored term, another does not) and read back as a VcUuid; an order index on a uuid field is refused when the declaration is checked, with the engine's reason `index_not_admitted`. - The crate's tests turn on stack-encrypt's `uuid` feature for the engine's UUID type. Cargo.lock records the uuid crate as a dependency of vitaminc-aead; no new package is added. `OneValue` stays. The engine encrypts one value as one ciphertext only through its opaque scalar path, which takes a type whose reference is a vitaminc `Scalar`. An OwnedFrame can hold an array or a map, so it is not one. `OneValue` is the type that checks the frame holds one scalar, or holds a JSON document, before the engine reads it.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
coderdan
left a comment
There was a problem hiding this comment.
Code review (/code-review medium) of 56a10b0. Five findings, all checked against the code: four nits inline, and one that is already on next, below.
Already on next (outside this PR): packages/stack-encrypt/Cargo.toml, the comment on the uuid feature, says "dynamic does not need it: the dynamic path refuses a uuid". That has been false since the dynamic path admitted ValueKind::Uuid, and this PR relies on it. I will correct it in the pull request for #1985, which changes stack-encrypt.
I will reply on each thread with what I changed.
| assert_eq!(opened.to_uuid(), id); | ||
|
|
||
| let sealed = keyset.encrypt(EngineUuid::new(id)).await.unwrap(); | ||
| let expected = OwnedFrame::of(EngineUuid::new(id)).unwrap(); |
There was a problem hiding this comment.
The SDK–engine UUID test skips the stored bytes. the_sdk_opens_what_the_engine_sealed_of_every_type sends each ciphertext through to_bytes and from_bytes before opening it; a_uuid_crosses_between_the_sdk_and_the_engine opens it in memory.
Failure scenario: A defect in writing or reading a UUID ciphertext's bytes would pass this test.
Severity: nit
There was a problem hiding this comment.
Fixed in eba70fb. The engine's UUID is now a case in the_sdk_opens_what_the_engine_sealed_of_every_type, which opens each ciphertext through to_bytes and from_bytes. The other direction is now the_engine_opens_a_uuid_the_sdk_sealed_from_its_stored_bytes.
The engine's UUID is now a case of the every-type test, which opens each ciphertext from its stored bytes. The other direction, the engine opening a UUID the SDK sealed, also reads it back from its bytes first.
A VcUuid takes hyphenated hex in either case, and decrypts as lowercase hyphenated hex. Other text, such as text in braces, of the wrong length or with a digit that is not hex, is an Err with vitaminc's code ERR_INVALID_UUID when it is encrypted, not a thrown exception. Tests: an uppercase VcUuid decrypts as lowercase, and the three kinds of malformed text are each an Err with ERR_INVALID_UUID whose message does not contain the text.
- Malformed UUID text in a record field is an Err with ERR_INVALID_UUID that names the field and the record. - A uuid field with null 'sealed' stores a null as a ciphertext of a value's length, and one with null 'sql' stores null. Both decrypt as null. - A uuid field with no null setting refuses a null, naming the field, with the engine's code stack_encrypt::dynamic_source.
cipherstash-agent
left a comment
There was a problem hiding this comment.
Review attestation
Reviewed 9133b315 · posted from Claude Code · claude-opus-5-5 · effort medium
Sources: code-review · claude-opus-5-5; mattpocock-skills:code-review (Standards and Spec agents) · claude-opus-5-5
Skills: code-review, rust-security, mattpocock-skills:code-review, review-cross-check, review-post
No correctness or security bug was found. rust-security found nothing in the Rust changes: the error for bad UUID text contains no plaintext, and nothing still refers to the removed Error::Uuid or is_uuid.
Findings (5): 5 minor. 2 are inline and 3 are below.
packages/stack-encrypt/src/value.rs:118(outside the diff) minor This adds to the review body about theCargo.tomluuidcomment. Thevalue::Uuidrustdoc says the same false thing: "The dynamic path … does not take a UUID yet: it refuses one". Fix it in #1985 as well.docs/plans/2026-11-22-recipher-typescript-sdk.md:593(outside the diff) minor The plan still says aVcUuidis "refused for now, withrecipher_js::uuid". This PR deletes that error code. The same out-of-date claim is at:601-604,:982and:1183.conformance/stack-encrypt/v1/record-scalars-v1.cases.json(outside the diff, on the base branch) minor Step 3 of #1821 is not done. No UUID case pins the equality-term bytes, and recipher-js runs no record corpus. A difference between how Go and TypeScript frame the 16 bytes would therefore pass every test.
Checked and not posted:
- Refuted: a
matchindex on a uuid field is untested. The engine testa_uuid_field_takes_equality_alone_and_holds_only_uuidsalready loops overmatch. - Refuted: the repeated UUID literal in the Rust tests. Each test compares only with its own copy.
- Already covered by the review body: the
stack-encrypt/Cargo.toml:152-153comment. - Not posted, as design choices for the author: the duplicated test helpers, inputs and doc comments; the parallel kind lists in
src/value-types.ts; and types that accept an index the engine refuses (all kinds, not only uuid).
Generated by Claude Code
| name: 'sensor', | ||
| }) | ||
| expect(result.isErr()).toBe(true) | ||
| expect(result.err()?.field).toBe('id') |
There was a problem hiding this comment.
minor This test checks only isErr() and field, so any refusal of id passes it, such as a later stack_encrypt::dynamic_source. Also assert expect(result.err()?.code).toBe('recipher_js::field_type') and record === 'devices', as the sibling refusal tests do.
Source: code-review, mattpocock-skills:code-review · claude-opus-5-5
Generated by Claude Code
There was a problem hiding this comment.
Fixed in a868956. The test now also asserts the code recipher_js::field_type, which I checked by running it, and record === 'devices'. The addon refuses the value before it reaches the engine, so there is no engine reason in fields.reason, as in the sibling test for an integer outside its field.
| '123e4567-e89b-12d3-a456-42661417400g', | ||
| ]) { | ||
| const pending = keyset.encrypt(new VcUuid(text)) | ||
| expect(pending, text).toBeInstanceOf(Promise) |
There was a problem hiding this comment.
minor Add a comment to say why this assertion is here. It catches encrypt returning a settled Result synchronously: await passes a non-thenable through unchanged, so every later assertion would still pass. Without the comment, it reads as if it guards against a synchronous throw, which would already fail on line 342.
Source: mattpocock-skills:code-review · claude-opus-5-5
Generated by Claude Code
There was a problem hiding this comment.
Fixed in a868956. A comment above the assertion says it catches encrypt returning a settled Result instead of a promise. await passes a non-thenable through unchanged, so the later assertions would still pass. A synchronous throw would already fail the line before.
The test that a uuid field refuses a string now asserts the code, recipher_js::field_type, and the record, as the other refusal tests do. Any refusal of the field passed before. The malformed UUID test says why it checks that encrypt returns a promise: await passes a settled Result through unchanged, so the other assertions would not notice.
coderdan
left a comment
There was a problem hiding this comment.
Human review. LGTM
Bring the UUID pull request up to date with the records pull request, which now carries the values pull request's review work: the wrapper classes are RcDate, RcTimestamp, RcDecimal and RcUuid, and the JSON conversion is in the value bridge. What the resolution kept from each side: - An RcUuid is a value here, as this branch has it. The addon's `uuid` error and the `is_uuid` check stay removed (`crate/src/error.rs`, `crate/src/js.rs`), with the tests and type tests that expected the refusal. This branch's UUID tests and docs stay, under the new name. - `src/values.ts`: the values branch's layout, each wrapper constant with its type beside it. RcUuid's doc is this branch's: how its text is read and how it decrypts. - `src/value-types.ts` and `src/kinds.ts`: this branch's `RcUuid` in `Scalar`, in `Opened` and as `kinds.uuid`, under the new names. - README: the values branch's text on a plain object and on the value bridge, with this branch's UUID row and paragraph. What the merge changed, which did not conflict: - `Ciphertext.fromBytes` takes only the kinds the package exports. This branch exports `kinds.uuid`, so `uuid` is in the addon's list. The addon suite's check of that list against `kinds` passes with it. - The test that pins the help of every error has no entry for the `uuid` error, which this branch removed. A UUID inside a JSON document is refused, as the other wrapper classes are: `recipher_js::not_json`. Cargo.lock and `native.d.ts` needed no change beyond the merge: `cargo metadata --locked` passes, and `build:debug` leaves the tree as it is.
Rewrite the comments, doc comments and README text that the UUID work added, so that each passes the plain-language checker. No code changes. - One idea in each sentence, and a list for the kinds of text that an `RcUuid` refuses. - A value "contains" its text, and a field "accepts" an index. - The comments say "encrypt" and "decrypt", as the README does.
The merge brings in the reworded error messages for values and records. This branch removes the `recipher_js::uuid` error, so the merge keeps that removal and drops the reworded text of that error.
…face 2 This merge brings the binding interface number 2 from the records branch. With it, the TypeScript refuses an older addon build when it loads. Six files conflicted, because the records branch changed the text that explains why the SDK refuses a UUID. This branch encrypts a UUID, and removes the `recipher_js::uuid` error and its check. The resolution keeps this branch's version of each conflict. So no doc or test on this branch says that the SDK cannot encrypt a UUID.
The rustdoc of `value::Uuid` said the dynamic path refuses a UUID. It has taken one as `ValueKind::Uuid` since the dynamic value model added the kind, and this branch relies on that. The `uuid` feature comment in `Cargo.toml` was corrected on `next` in 85c1605. This fixes the same claim in the rustdoc.
Mutation testing (cargo-mutants,
|
|
This replies to the findings in the bodies of reviews 6088811683 and 6088950813. The inline threads have their own replies.
|
- JSON numbers: a whole number of 2^64 or more is a float on either side of zero. A negative integer below -2^63 and above -2^64 has no form in a document, because the number and the bigint are both refused. - Adapter: an integer read from an integer column comes back as a bigint when it is outside the safe range, so every stored row can be read. On the way in, a whole number outside the safe range is still refused. - Nesting: both limits are now counted in levels down from the top, and the plan says a Json is never inside a value tree. - UUID: step 2 covers every type except VcUuid. After #1996, a VcUuid encrypts as a value on its own as well as in a record field.
The second review of #2019 found the plan out of step with the code. - The wrapper classes are RcDate, RcTimestamp, RcDecimal, and RcUuid in #1775, #1776, and #1996. The plan used vitaminc's Vc names. The plan now uses the Rc names, and says once that #1775 renamed them. - The JSON number rules are now one table, with a row for each range of whole numbers. Each range includes both ends. The table shows the new refusal below -2^63. That refusal says the integer has no exact form. The plan also says that NaN and the infinities are refused. - The round trip of 2^64 - 1 is tested on the native build only. The plan now names that test, and says the wasm build is planned. - The UUID cell no longer repeats the refusal before #1996. - The header now gives the status. Step 1 is built. The next steps are in open pull requests.
The records branch now has next, the single-value path through the
engine's dynamic::value::encrypt, and encrypt's { kind } options.
Conflicts, and how they were resolved:
- README.md: the RcUuid row stays. The null row is the records
branch's row. It points to the declared kind section. That section now
lists a UUID as a fixed-width kind.
- values.test.ts: the UUID round trips stay. The null round trip is
gone, because a lone null is refused. The test that checks the refusal
of a fixed-width null, until #2023 merges, covers kinds.uuid too. The
test of an unknown kind uses the name text, since uuid is now a kind.
- kinds.ts: both imports stay, and uuid is a fixed-width kind name, so
encrypt(null, { kind: kinds.uuid }) type-checks.
Outside the conflicts, the help of recipher_js::null_value names a UUID
among the fixed-width types, and a records type test puts the row in a
variable. The new encrypt overloads moved where TypeScript reports the
error for an object literal, so the @ts-expect-error no longer matched.
Summary
The TypeScript addon now encrypts a
VcUuidas the engine's UUID, instead of refusing it withrecipher_js::uuid. A record field declaredkinds.uuidis stored, found by equality and read back as aVcUuid. This is the TypeScript part of #1821. Go's part is #1994.This pull request goes into #1776 (
feat/recipher-js-records), which needs the records API to query a UUID. Both #1775 and #1776 were brought up to date withnextfirst. See the comments on those pull requests.Refs #1821.
Changes
is_uuidand the read-time check incrate/src/js.rs.Error::Uuid(recipher_js::uuid) incrate/src/error.rs.VcUuidis refused.VcUuidis aScalar,Opened<VcUuid>isVcUuid, andkinds.uuidis a new kind.VcUuidround trip, andCiphertext.fromBytes(bytes, kinds.uuid), which refuses a UUID that was encrypted as a string.devicesrecord whoseidfield is a uuid with an equality index. The stored equality term matchesencryptFieldfor the same UUID and not for another. The row decrypts withidas aVcUuid. A string for that field is refused, naming the field.oreoropeindex on a uuid field is refused bycheckDeclarationsand byCipher.create, withindex_not_admitted.VcUuidandkinds.uuid.stack-encryptturns on itsuuidfeature, soCargo.lockgains one dependency edge. No new package is added.Verification
recipher-js: fmt, clippy (--all-targetsand--all-features) with-D warnings, cargo tests, andcargo metadata --locked.typecheck,test:addon85/85, and Biome on the package.scripts/__tests__/recipher-js*tests, 16/16.native.d.tsis unchanged.value-napi/tests/addon, which this change does not touch, and the repo-widepnpm test.Review notes
OneValuestays. The engine's single-value encrypt needs a vitamincScalar, and anOwnedFramecan hold an array or a map. Deleting it needs that engine path to accept a frame holding one scalar.@cipherstash/recipheris private, so there is no changeset.next: a comment inpackages/stack-encrypt/Cargo.tomlsays the dynamic path refuses a uuid. That is no longer true. It is outside this branch.